<template >
	<view class="container">
		<view v-if="isViewType==1" class="lawyer">
			<view @click="testClick" class="navTitle" :style="{ marginTop: `${statusBarHeight}px`}">
				办公
			</view>
			<view class="flex-row-center" @click="goAuthClick">
				<image class="container1" src="/static/logo.png"></image>
				<view class="title">
					欢迎使用 律师人工智能办案系统
				</view>
			</view>
			<u-swiper
				height="336rpx"
				:list="lawyerCycleList"
				:indicator="true"
				@click="cycleDetail"
				indicatorActiveColor="#E93548"
				:circular="true"
				indicatorMode="dot"
				keyName="image"
			></u-swiper>
			<view class="wrapView">
				<view @click="lawyerItemClick(item)" v-for="(item,index) in lawyerList" :key="index" class="wrapItem flex-column-center">
					<image style="width: 72rpx;height: 72rpx;" :src="item.icon"></image>
					<view style="font-family: PingFang SC, PingFang SC;font-weight: 500;font-size: 30rpx;color: #FFFFFF;margin-top: 8rpx;">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<u-action-sheet @close="chooseCaseTypeClick" @select="selectClick" :actions="caseTypeList" :closeOnClickOverlay="true" :closeOnClickAction="true" :show="isShowCaseType"></u-action-sheet>
		
		<u-popup :round="10" mode="center" bgColor="transparent" closeOnClickOverlay="true" :show="isShowRuZhuRule" @close="goRenZhengClick">
			<view class="lawyerVipView">
				<view class="lawyerVipTitle">
					入驻声明
				</view>
				<view class="lawyerVipContent">
					(1) 损害国家荣誉和利益的；<br/>
					(2) 煽动民族仇恨、民族歧视，破坏民族团结的；<br/>
					(3) 破坏国家宗教政策，宣扬邪教和封建迷信的；<br/>
					(4) 散布谣言，扰乱社会秩序，破坏社会稳定的；<br/>
					(5) 散布淫秽、色情、赌博、暴力、凶杀、恐怖或者教唆犯罪的；<br/>
					(6) 侮辱或者诽谤他人，侵害他人合法权益的；<br/>
					(7) 含有法律、行政法规禁止的其他内容的信息。<br/>
					不得在本系统涉及违法、违规、违纪的行为，否则有主管机关处理，需要管理方提供信息的，管理方有权提供给主管机关。<br/>
					冒用律师、律所名字入驻的，一经查实停止使用，移交公安机关，主管机关处理。
				</view>
				
		    </view> 
			<view @click="goRenZhengClick()" class="loginButton">
				我已知晓，去认证
			</view>
		</u-popup>
		
		<u-popup :round="10" mode="center" bgColor="transparent" closeOnClickOverlay="true" :show="isShowQuXuFei" @close="goQuXuFeiClick">
			<view class="lawyerVipView2 flex-column-center">
				<view class="lawyerVipContent5">
					免费使用已到期
				</view>
				<view class="lawyerVipContent2">
					需要续费才能使用此功能
				</view>
				<view class="flex-row-center" style="margin-top: 48rpx;">
					<view @click="goQuXuFeiClick" class="lawyerVipContent3">
						取消
					</view>
					<view class="lawyerVipContent4">
						去续费
					</view>
				</view>
		    </view> 
		</u-popup>
		
		<view v-if="isViewType==2" class="lawOffice">
			<view class="lawOfficeTopView">
				<view @click="testClick" class="navTitle" :style="{ marginTop: `${statusBarHeight}px`}">
					办公
				</view>
				<view class="flex-row-center" @click="goAuthOfficeClick">
					<image class="container1" src="/static/logo.png"></image>
					<view class="title">
						欢迎使用 律师人工智能办案系统
					</view>
				</view>
				<u-swiper
					height="336rpx"
					:list="lawOfficeCycleList"
					:indicator="true"
					@click="cycleDetail"
					indicatorActiveColor="#E93548"
					:circular="true"
					indicatorMode="dot"
					keyName="image"
				></u-swiper>
			</view>
			<view class="wrapViewOffice">
				<view @click="lawOfficeListItemClick(item)" v-for="(item,index) in lawOfficeList" :key="index" class="wrapOfficeItem flex-row-center">
					<image style="width: 72rpx;height: 72rpx;" :src="item.icon"></image>
					<view style="font-family: PingFang SC, PingFang SC;font-weight: 500;font-size: 32rpx;color: #333333;margin-left: 20rpx;">
						{{item.name}}
					</view>
					<view class="msgNum">
						1
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script> 
	import BaseData from "@/Network/RequestURL/baseData.js"
	
	export default {
		data() {
			return {
				isViewType: 1,//可以默认0   1律师端   2律所端
				statusBarHeight: '',
				barHeight: '',
				
				isShowRuZhuRule:false,
				isShowQuXuFei:false,
				/*-----------以上--公共数据---------*/
				lawOfficeList:BaseData.lawOfficeList,//律所端 首页 功能Item列表
				
				
				/*-------------律所端------以上-----------*/
				 
				/*-------------律师端------以下-----------*/ 
				isShowCaseType:false,//案件类型弹窗是否显示
				caseTypeList:BaseData.caseTypeList,//案件类型列表
				lawyerList:BaseData.lawyerList,//律师端 首页 功能Item列表
				lawyerCycleList:[],
				lawOfficeCycleList:[],
				
			};
		},
		onShow() {
			// isViewType //可以默认0   1律师端   2律所端
			
			let sysInfo = uni.getSystemInfoSync()
			// console.log('sysInfo--------',sysInfo)
			// 状态栏高度
			this.statusBarHeight = sysInfo.statusBarHeight; 
			// 胶囊数据
			const { top, height } = wx.getMenuButtonBoundingClientRect();
			// 自定义导航栏高度 = 胶囊高度 + 胶囊的padding*2, 如果获取不到设置为38
			this.barHeight = height ? height + (top - this.statusBarHeight) * 2 : 38;
		},
		onLoad() {
			// this.isShowRuZhuRule = true
			this.isShowQuXuFei = true
			
			this.loginReq()
			this.getLawyerCyclePicData()
			this.getLawOfficeCyclePicData()
		},
		methods: {
			//无感登录
			async loginReq(){
				uni.login({
					success :(res)=> {
						if (res.code) {
							console.log(res)
							let param = {
								'url':`/loginuser/LoginByWx`,
								'data':{
									code: res.code,
									appid: 'wx69feaa2fad8be0db'
								},
								'method':'POST'
							}
							uni.showLoading({})
							this.$myRequest(param).then(res=>{
								uni.hideLoading()
								if (res.code==200) {
									uni.setStorageSync('token', res.data.token)
									this.getUserInfoData()
								}
							})
						} else {
							console.log('登录失败！' + res.errMsg)
						}
					},
					fail: (error) => {
						uni.showLoading({})
					}
				})
			},
			async getUserInfoData(){
				let param = {
					'url':`/loginuser/info`,
					'data':{
						code: res.code,
						appid: 'wx69feaa2fad8be0db'
					},
					'method':'POST'
				}
				uni.showLoading({})
				this.$myRequest(param).then(res=>{
					uni.hideLoading()
					if (res.code==200) {
						uni.setStorageSync('token', res.data.token)
						
					}
				})
			},
			//律师端轮播图
			async getLawyerCyclePicData(){
				let param = {
					'url':`/carousel/list`,
					'data':{
						// type:0 //0是律师端 1 是律所的
					},
					'method':'POST'
				}
				// uni.showLoading({})
				this.$myRequest(param).then(res=>{
					uni.hideLoading()
					if (res.code==200) {
						this.lawyerCycleList = res.data.datalist
					}
				})
			},
			//律所端轮播图
			async getLawOfficeCyclePicData(){
				let param = {
					'url':`/carousel/list`,
					'data':{
						// type:1 //0是律师端 1 是律所的
					},
					'method':'POST'
				}
				// uni.showLoading({})
				this.$myRequest(param).then(res=>{
					uni.hideLoading()
					if (res.code==200) {
						this.lawOfficeCycleList = res.data.datalist
					}
				})
			},
			
			testClick(){
				this.isViewType = this.isViewType==1?2:1;
			},
			
			goRenZhengClick(){
				this.isShowRuZhuRule = false
			},
			goQuXuFeiClick(){
				this.isShowQuXuFei = false
			},
			/*-------------律师端-----------------*/ 
			//律师端 轮播图点击事件
			cycleDetail(index){
				console.log(index)
				/*-------选择文档功能示例---------*/
				// wx.chooseMessageFile({
				//   count: 1, //默认100
				//   extension:['.zip','.doc','.docx','.pdf'],
				// 	success: (res) => {
				// 		console.log('res--------------',res);
				// 	},
				// 	fail: (error) => {
				// 		console.log('error------------',error);
				// 	}
				// });
			},
			//律师认证
			goAuthClick(){
				uni.navigateTo({
					url:'/pages/register/register'
				})
			},
			chooseCaseTypeClick(){
				this.isShowCaseType = false
			},
			//律师端 Item点击事件
			lawyerItemClick(item){
				switch (item.name){
					case '案件登记':
					{
						this.isShowCaseType = true
					}
						break;
					case '电签委托合同':
					{
						uni.navigateTo({
							url:'/pageB/dianQianWeiTuoHeTong/dianQianWeiTuoHeTong'
						})
					}
						break;
					case '一键开票':
					{
						uni.navigateTo({
							url:'/pageB/YiJianKaiPian/YiJianKaiPian'
						})
					}
						break;
					case '远程函书':
					{
						uni.navigateTo({
							url:'/pageB/YuanChengHanShu/YuanChengHanShu'
						})
					}
						break;
					case '电子归档':
					{
						uni.navigateTo({
							url:'/pageB/dianZiGuiDang/dianZiGuiDang' 
						})
					}
						break;
					case '信息查询':
					{
						uni.navigateTo({
							url:'/pageB/XinXiChaXun/XinXiChaXun' 
						})
					}
						break;
					case '法律计算器':
					{
						uni.navigateTo({
							url:'/pageB/FaLvJiSuanQi/FaLvJiSuanQi' 
						})
					}
						break;
					case 'AI预审判决':
					{
						uni.navigateTo({
							url:'/pageB/AIYuShenPanJue/AIYuShenPanJue' 
						})
					}
						break;
					case 'AI律师助手':
					{
						uni.navigateTo({
							url:'/pageB/AILvShiZhuShou/AILvShiZhuShou' 
						})
					}
						break;
					default:
						break;
				}
			},
			selectClick(item){
				this.isShowCaseType = false
				console.log(item)
				switch (item.name){
					case "民事":
					{
						uni.navigateTo({
							url:'/pageA/minShiRegistration/minShiRegistration'
						})
					}
						break;
					case "行政":
					{
						uni.navigateTo({
							url:'/pageA/xingZhengRegistration/xingZhengRegistration'
						})
					}
						break;
					case "刑事":
					{
						uni.navigateTo({
							url:'/pageA/criminalRegistration/criminalRegistration'
						})
					}
						break;
					case "仲裁":
					{
						uni.navigateTo({
							url:'/pageA/zhongCaiRegistration/zhongCaiRegistration'
						})
					}
						break;
					case "非诉":
					{
						uni.navigateTo({
							url:'/pageA/feiSuRegistration/feiSuRegistration'
						})
					}
						break;
					default:
						break;
				}
				
			},
			/*-------------律所端-----------------*/ 
			//律所认证
			goAuthOfficeClick(){
				uni.navigateTo({
					url:'/pages/registerOffice/registerOffice'
				})
			},
			lawOfficeListItemClick(item){
				switch (item.name){
					case '案件列表':
					{
						uni.navigateTo({
							url:'/pageE/caseList/caseList'
						})
					}
						break;
					case '待审批':
					{
						uni.navigateTo({
							url:'/pageE/DaiShenPi/DaiShenPi'
						})
					}
						break;
					case '律师管理':
					{
						uni.navigateTo({
							url:'/pageE/lawyerManager/lawyerManager'
						})
					}
						break;
					case '一键开票':
					{
						uni.navigateTo({
							url:'/pageE/officeYiJianKaiPiao/officeYiJianKaiPiao'
						})
					}
						break;
					case '收款信息':
					{
						uni.navigateTo({
							url:'/pageE/ShouKuanXinXi/ShouKuanXinXi'
						})
					}
						break;
					case '审批管理':
					{
						uni.navigateTo({
							url:'/pageE/shenPiManager/shenPiManager'
						})
					}
						break;
					default:
						break;
				}
			}
			
		},
	};
</script>

<style lang="scss">
	.lawyerVipContent5{
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #333333;
	}
	.lawyerVipContent2{
		margin-top: 12rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #666666;
	}
	.lawyerVipContent3{
		width: 236rpx;
		height: 80rpx;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		border: 3rpx solid;
		border-image: linear-gradient(136deg, rgba(233, 53, 72, 1), rgba(243, 91, 67, 1)) 3 3;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #E93548;
		line-height: 80rpx;
		text-align: center;
	}
	.lawyerVipContent4{
		margin-left: 20rpx;
		width: 236rpx;
		height: 80rpx;
		background: linear-gradient( 136deg, #E93548 0%, #F35B43 100%);
		box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(235,43,59,0.4);
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
	}
	.lawyerVipView2{
		padding-top: 40rpx;
		padding-bottom: 40rpx;
		width: 674rpx;
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}
	.loginButton {
		margin-top: 40rpx;
		margin-left: 24rpx;
		width: 620rpx;
		height: 90rpx;
		background: linear-gradient( to bottom, #E93548 0%, #F35B43 100%);
		box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(235,43,59,0.4);
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 90rpx;
		text-align: center;
	}
	.lawyerVipContent{
		width: 626rpx;
		padding: 24rpx;
	}
	.lawyerVipTitle{
		width: 674rpx;
		height: 90rpx;
		background: linear-gradient( 136deg, #E93548 0%, #F35B43 100%);
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #FFFFFF;
		line-height: 90rpx;
		text-align: center;
	}
	.lawyerVipView{
		padding-bottom: 10rpx;
		width: 674rpx;
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}
	.wrapViewOffice{
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		align-content: space-between;
		margin-left: 3rpx;
		margin-top: 630rpx;
	}
	.wrapOfficeItem{
		margin-left: 20rpx;
		margin-top: 20rpx;
		width: 340rpx;
		height: 160rpx;
		background: #FFFFFF;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		// position: absolute;
	}
	.msgNum{
		position: relative;
		right: 0rpx;
		top: -22rpx;
		width: 36rpx;
		height: 36rpx;
		background: #E93548;
		border-radius: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #FFFFFF;
		line-height: 36rpx;
		text-align: center;
	}
	.lawOfficeTopView{
		position: absolute;
		top: 0rpx;
		left: 0rpx;
		width: 750rpx;
		height: 610rpx;
		background: linear-gradient( to bottom, #EB2B3B 0%, rgba(243,91,67,0) 100%);
	}
	.lawOffice{
		position: fixed;
		top: 0rpx;
		bottom: 0rpx;
		left: 0rpx;
		right: 0rpx;
		background: #FAF7F8;
	}
	/*-------------律所端------以上css-----------*/ 
	page {
		
	}
	/*-------------律师端------以下css-----------*/ 
	.wrapView{
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		align-content: space-between;
		margin-left: 2rpx;
		margin-top: 18rpx;
	}
	.wrapItem{
		margin-left: 22rpx;
		margin-top: 22rpx;
		width: 220rpx;
		height: 172rpx;
		background-color: rgba(217,217,217, 0.3);
		border-radius: 4rpx 4rpx 4rpx 4rpx;
	}
	::v-deep.u-swiper {
		width: 702rpx;
		margin-left: 24rpx;
		margin-top: 36rpx;
	}
	.lawyer{
		position: fixed;
		top: 0rpx;
		bottom: 0rpx;
		left: 0rpx;
		right: 0rpx;
		background: linear-gradient( to bottom, #E93548 0%, #F35B43 100%);
	}
	.container1{
		background-color: white;
		width: 54rpx;
		height: 56rpx;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
	}
	.title {
		margin-left: 14rpx;
		font-family: ZhenyanGB, ZhenyanGB;
		font-weight: 400;
		font-size: 40rpx;
		color: #FFFFFF;
	}
	.navTitle{
		width: 750rpx;
		height: 88rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 36rpx;
		color: #FFFFFF;
		line-height: 88rpx;
		text-align: center;
	}
	
</style>